package swb.api.com.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import swb.api.com.service.AuthService;
import swb.api.com.vo.req.LoginRequest;

@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    /**
     * 用户登录接口
     */
    @PostMapping("/login")
    public ResponseEntity<?> login(@RequestBody LoginRequest loginRequest) {
        try {
            return ResponseEntity.ok(authService.login(loginRequest));
        } catch (Exception e) {
            return ResponseEntity.badRequest().body(e.getMessage());
        }
    }

    /**
     * 用户登出接口
     */
    @PostMapping("/logout")
    public ResponseEntity<String> logout() {
        // 实际实现中需要处理token失效逻辑
        return ResponseEntity.ok("登出成功");
    }
}
